package com.spc.car.data.service.sys.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.spc.car.data.entity.sys.SysRoleMenu;
import com.spc.car.data.mapper.sys.SysRoleMenuMapper;
import com.spc.car.data.service.sys.SysRoleMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 角色和菜单关联表 服务实现类
 * </p>
 *
 * @author 
 * @since 2020-03-06
 */
@Service
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements SysRoleMenuService {

    @Override
    public int checkMenuExistRole(Long menuId) {
        return count(new QueryWrapper<SysRoleMenu>().eq("menu_id", menuId));
    }

    @Override
    public int deleteRoleMenuByRoleId(Long roleId) {
        return baseMapper.delete(new QueryWrapper<SysRoleMenu>().eq("role_id", roleId));
    }

    @Override
    public boolean batchRoleMenu(List<SysRoleMenu> roleMenuList) {

        return saveOrUpdateBatch(roleMenuList);
    }
}
